package com.itheima.method.method4;

public class Test5 {
    public static void main(String[] args) {
        int[] arr = {11, 55, 33, 22, 44};
        int[] MaxAndMin = getMaxAndMin(arr);

        System.out.println(MaxAndMin[0]);
        System.out.println(MaxAndMin[1]);

    }

    public static int[] getMaxAndMin(int[] arr) {
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        int min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (min > arr[i]) {
                min = arr[i];
            }
        }
        int[] maxAndMin = {min, max};
        return maxAndMin;
    }
}